﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using eCommerce.core.Helpers;
using eCommerce.db.BORespository;
using eCommerce.db;
using System.Web.Configuration;
using eCommerce.core;

namespace eCommerce.web.Controls.Sidebar
{
    public partial class Poster : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var PageType = Utils.GetIdFromRequestString(Utils.PageType, string.Empty);
            var categoryName = Utils.GetIdFromRequestString(Utils.Name, string.Empty);
            var parentcategoryName = Utils.GetIdFromRequestString(Utils.Parent_Name, string.Empty);

            if (PageType == "2")
            {
                categoryName = (!string.IsNullOrEmpty(parentcategoryName)) ? parentcategoryName + "/" + categoryName : categoryName;

                var o = CategoryBo.GetByUrl(categoryName);
                if (o != null)
                {
                    if (!String.IsNullOrEmpty(o.ImagePath))
                        ltrImg.Text = string.Format(Constant.ThumbImage, WebConfigurationManager.AppSettings["Thumbnail"], o.ImagePath, (int)SettingType.Category, 886);
                }
            }
            else
                this.Visible = false;
        }
    }
}